package org.gd136.ce.util;

import org.gd136.ce.action.CallAction;
import org.gd136.ce.game.GS;
import org.gd136.ce.manager.RM;
import org.gd136.ce.stage.Layer;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

public class U {

	public static final Image createMask(Layer layer) {
		Image mask = RM.colorImage();
		Stage stage = GS.stage;
		stage.addActor(mask);
		mask.setColor(Color.BLACK);
		mask.setSize(stage.getWidth(), stage.getHeight());
		return mask;
	}

	public static final void transLayer(final Layer old, final Layer now) {
		Image mask = createMask(old);
		mask.getColor().a = 0;
		mask.addAction(Actions.sequence(Actions.fadeIn(0.35f),
				CallAction.create(() -> {
					GS.stage.addActor(now);
					GS.stage.addActor(mask);
					old.remove();
				}), Actions.fadeOut(0.35f), Actions.removeActor()));
	}

}
